package dormouse.fx.renderers;

import javafx.scene.Node;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import dormouse.vfs.ui.renderers.IFileRenderer;

public class ImageRenderer extends ImageView implements IFileRenderer<Node> {
	
	/** Class logger.*/
	private static final Logger log = LoggerFactory
			.getLogger(ImageRenderer.class);
	
	private static String[] EXTS = new String[]{"jpg","jpeg","png"};

	@Override
	public void render(FileObject file) {
		Image image = null;
		try {
			image = new Image(file.getContent().getInputStream());
			this.setImage(image);
		} catch (FileSystemException e) {
			log.error(e.getMessage(), e);
		}
		
		
	}

	@Override
	public Node getComponent() {
		return this;
	}

	@Override
	public String[] getFileExtensions() {
		return EXTS;
	}

}
